<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="app" uri="http://www.wanrenhui.com"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@include file="/res/include/base-head.jsp"%>
<%@include file="/res/include/jquery-easyui.jsp"%>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/res/js/pubUpgrade/pubUpgradeVersion.js"></script>
</head>
<body>

	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'north',border:false,split:false">
	    	<form id="query-form" class="search_form clearfix">
		    	<p class="search_form_btn">
		         <input type="button" value="新增" class="icon_serach" onclick="toAdd()" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	            	<input type="button" value="原生发布" class="icon_serach" onclick="updateNative()" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	            	<input type="button" value="原生安卓发布" class="icon_serach" onclick="upgradeNativeAndroid()" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	            	<input type="button" value="原生IOS发布" class="icon_serach" onclick="upgradeNativeIos()" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	            	<input type="button" value="增量发布" class="icon_serach" onclick="updateByVersion()" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	            </p>
	        </form>
	  	</div>
		<div data-options="region:'center',border:false">
			<table id="datagrid"
				data-options="url:'${pageContext.request.contextPath}/pub/upgradeversion/list',toolbar:'#toolbar'">
				<thead>
					<tr>
						<th data-options="field:'currVersion',width:100">当前版本号</th>
						<th data-options="field:'toVersion',width:100">目标版本号</th>
						<th
							data-options="field:'androidFile',width:400,align:'center'">安卓更新地址</th>
						<th data-options="field:'iosFile',width:400,align:'center'">ios更新地址</th>
						<th data-options="field:'remark',width:100">描述</th>
						<th data-options="field:'id',align:'center',width:150,formatter:formatOperation">管理操作</th>
					</tr>
				</thead>
			</table>
		</div>
	</div>
	<script>
		function formatOperation(value,row,index) {
			var l_html = '';
			l_html += '<a href="javascript:;" class="table_link" id='+row.id+' onclick="admin.pubUpgradeVersion.toUpdate(this)">编辑</a>';
			l_html += '<a href="javascript:;" class="table_link" onclick="admin.pubUpgradeVersion.del('+row.id+')">删除</a>';
			return l_html;
		}
		function upgradeNativeIos(){
			 var url = contextPath + '/pub/upgrade/upgradeNativeIos';
				$.post(url, {}, function (result) {
					if (result.code == 1) {
						top.showInfo('原生IOS发布成功');
					} else {
						top.showInfo(result.msg);
					}
				});
		}
		function upgradeNativeAndroid(){
			 var url = contextPath + '/pub/upgrade/upgradeNativeAndroid';
				$.post(url, {}, function (result) {
					if (result.code == 1) {
						top.showInfo('原生安卓发布成功');
					} else {
						top.showInfo(result.msg);
					}
				});
		}
		function updateNative(){
			 var url = contextPath + '/pub/upgrade/updateNative';
				$.post(url, {}, function (result) {
					if (result.code == 1) {
						top.showInfo('原生发布成功');
					} else {
						top.showInfo(result.msg);
					}
				});
		}
		function updateByVersion(){
			var url = contextPath + '/pub/upgrade/updateByVersion';
			$.post(url, {}, function (result) {
				if (result.code == 1) {
					top.showInfo('增量发布成功');
				} else {
					top.showInfo(result.msg);
				}
			});
		}
		function toAdd(){
			top.addTab('','新增', contextPath+'/pub/upgradeversion/toAdd');
		}
	</script>
</body>
</html>
